{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 第一次作业"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 刘星雨    202122011132"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 题目一"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "有一个这样的DNA核酸序列\n",
    "\n",
    "“AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC”\n",
    "\n",
    "请把这个核酸序列存入一个list，并数一数A、G、C、T各有多少个。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20 17 12 21\n"
     ]
    }
   ],
   "source": [
    "string = 'AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC'\n",
    "DNA = list(string)\n",
    "#print(DNA)\n",
    "num_A,num_G,num_C,num_T = 0,0,0,0\n",
    "\n",
    "for dna in DNA:\n",
    "    if dna == 'A':\n",
    "        num_A += 1\n",
    "    elif dna == 'G':\n",
    "        num_G += 1\n",
    "    elif dna == 'C':\n",
    "        num_C += 1\n",
    "    else:\n",
    "        num_T += 1\n",
    "print(num_A,num_G,num_C,num_T)\n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 题目二"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "一个花样滑冰运动员表演后，裁判给表演内容进行评分，分数从0.25分到10分，每次增加值为0.25分。\n",
    "\n",
    "试生成一个元组，把可能的得分存入元组，并遍历元组的每一项，打印“一个运动员可能得_____分”。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "An athlete may get 0.25 points.\n",
      "An athlete may get 0.5 points.\n",
      "An athlete may get 0.75 points.\n",
      "An athlete may get 1.0 points.\n",
      "An athlete may get 1.25 points.\n",
      "An athlete may get 1.5 points.\n",
      "An athlete may get 1.75 points.\n",
      "An athlete may get 2.0 points.\n",
      "An athlete may get 2.25 points.\n",
      "An athlete may get 2.5 points.\n",
      "An athlete may get 2.75 points.\n",
      "An athlete may get 3.0 points.\n",
      "An athlete may get 3.25 points.\n",
      "An athlete may get 3.5 points.\n",
      "An athlete may get 3.75 points.\n",
      "An athlete may get 4.0 points.\n",
      "An athlete may get 4.25 points.\n",
      "An athlete may get 4.5 points.\n",
      "An athlete may get 4.75 points.\n",
      "An athlete may get 5.0 points.\n",
      "An athlete may get 5.25 points.\n",
      "An athlete may get 5.5 points.\n",
      "An athlete may get 5.75 points.\n",
      "An athlete may get 6.0 points.\n",
      "An athlete may get 6.25 points.\n",
      "An athlete may get 6.5 points.\n",
      "An athlete may get 6.75 points.\n",
      "An athlete may get 7.0 points.\n",
      "An athlete may get 7.25 points.\n",
      "An athlete may get 7.5 points.\n",
      "An athlete may get 7.75 points.\n",
      "An athlete may get 8.0 points.\n",
      "An athlete may get 8.25 points.\n",
      "An athlete may get 8.5 points.\n",
      "An athlete may get 8.75 points.\n",
      "An athlete may get 9.0 points.\n",
      "An athlete may get 9.25 points.\n",
      "An athlete may get 9.5 points.\n",
      "An athlete may get 9.75 points.\n",
      "An athlete may get 10.0 points.\n"
     ]
    }
   ],
   "source": [
    "#元组做\n",
    "a = tuple(i/4 for i in range(1,41)) #不可以是浮点数\n",
    "for i in a:\n",
    "    print(f\"An athlete may get {i} points.\")\n",
    "    #print(\"An athlete may get\",i,\"points。\",sep='') #去掉空格"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "An athlete may get 0.25 point.\n",
      "An athlete may get 0.5 point.\n",
      "An athlete may get 0.75 point.\n",
      "An athlete may get 1.0 point.\n",
      "An athlete may get 1.25 point.\n",
      "An athlete may get 1.5 point.\n",
      "An athlete may get 1.75 point.\n",
      "An athlete may get 2.0 point.\n",
      "An athlete may get 2.25 point.\n",
      "An athlete may get 2.5 point.\n",
      "An athlete may get 2.75 point.\n",
      "An athlete may get 3.0 point.\n",
      "An athlete may get 3.25 point.\n",
      "An athlete may get 3.5 point.\n",
      "An athlete may get 3.75 point.\n",
      "An athlete may get 4.0 point.\n",
      "An athlete may get 4.25 point.\n",
      "An athlete may get 4.5 point.\n",
      "An athlete may get 4.75 point.\n",
      "An athlete may get 5.0 point.\n",
      "An athlete may get 5.25 point.\n",
      "An athlete may get 5.5 point.\n",
      "An athlete may get 5.75 point.\n",
      "An athlete may get 6.0 point.\n",
      "An athlete may get 6.25 point.\n",
      "An athlete may get 6.5 point.\n",
      "An athlete may get 6.75 point.\n",
      "An athlete may get 7.0 point.\n",
      "An athlete may get 7.25 point.\n",
      "An athlete may get 7.5 point.\n",
      "An athlete may get 7.75 point.\n",
      "An athlete may get 8.0 point.\n",
      "An athlete may get 8.25 point.\n",
      "An athlete may get 8.5 point.\n",
      "An athlete may get 8.75 point.\n",
      "An athlete may get 9.0 point.\n",
      "An athlete may get 9.25 point.\n",
      "An athlete may get 9.5 point.\n",
      "An athlete may get 9.75 point.\n",
      "An athlete may get 10.0 point.\n"
     ]
    }
   ],
   "source": [
    "#列表简便循环\n",
    "all_scores = [x/4 for x in range(1,41)]\n",
    "for scores in all_scores:\n",
    "    print(f\"An athlete may get {scores} point.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "An athlete may get 0.25 point.\n",
      "An athlete may get 0.5 point.\n",
      "An athlete may get 0.75 point.\n",
      "An athlete may get 1.0 point.\n",
      "An athlete may get 1.25 point.\n",
      "An athlete may get 1.5 point.\n",
      "An athlete may get 1.75 point.\n",
      "An athlete may get 2.0 point.\n",
      "An athlete may get 2.25 point.\n",
      "An athlete may get 2.5 point.\n",
      "An athlete may get 2.75 point.\n",
      "An athlete may get 3.0 point.\n",
      "An athlete may get 3.25 point.\n",
      "An athlete may get 3.5 point.\n",
      "An athlete may get 3.75 point.\n",
      "An athlete may get 4.0 point.\n",
      "An athlete may get 4.25 point.\n",
      "An athlete may get 4.5 point.\n",
      "An athlete may get 4.75 point.\n",
      "An athlete may get 5.0 point.\n",
      "An athlete may get 5.25 point.\n",
      "An athlete may get 5.5 point.\n",
      "An athlete may get 5.75 point.\n",
      "An athlete may get 6.0 point.\n",
      "An athlete may get 6.25 point.\n",
      "An athlete may get 6.5 point.\n",
      "An athlete may get 6.75 point.\n",
      "An athlete may get 7.0 point.\n",
      "An athlete may get 7.25 point.\n",
      "An athlete may get 7.5 point.\n",
      "An athlete may get 7.75 point.\n",
      "An athlete may get 8.0 point.\n",
      "An athlete may get 8.25 point.\n",
      "An athlete may get 8.5 point.\n",
      "An athlete may get 8.75 point.\n",
      "An athlete may get 9.0 point.\n",
      "An athlete may get 9.25 point.\n",
      "An athlete may get 9.5 point.\n",
      "An athlete may get 9.75 point.\n",
      "An athlete may get 10.0 point.\n"
     ]
    }
   ],
   "source": [
    "#列表 while + append\n",
    "score = 0\n",
    "all_scores = []\n",
    "while score < 10:\n",
    "    score += 0.25\n",
    "    all_scores.append(score)\n",
    "#print(all_scores)\n",
    "for scores in all_scores:\n",
    "    print(f\"An athlete may get {scores} point.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 题目三"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "创建一个字典，列出你所了解的地域美食，比如{'肠粉':{'城市':'广州','原料':'米'}}。当然，你可以做的更丰富一些。 最后遍历你熟悉的美食，打印出，类似如下的句子：“肠粉是广州的一种美食，它的主要原料是米”。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "肠粉是广州的一种美食，它的主要原料是米。\n",
      "蒲菜是淮安的一种美食，它的主要原料是菜。\n",
      "红肠是哈尔滨的一种美食，它的主要原料是肉。\n"
     ]
    }
   ],
   "source": [
    "delicacy = {\n",
    "    '肠粉':{'城市':'广州','原料':'米'},\n",
    "    '蒲菜':{'城市':'淮安','原料':'菜'},\n",
    "    '红肠':{'城市':'哈尔滨','原料':'肉'},\n",
    "}\n",
    "for name,information in delicacy.items():\n",
    "    print(f\"{name}是{information['城市']}的一种美食，它的主要原料是{information['原料']}。\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
